{template 'common/header'}

<ul class="nav nav-tabs">
	<li {if empty($id)}class="active"{/if}><a href="{url 'mc/fields'}">字段管理</a></li>
	{if !empty($id)}<li class="active"><a href="{php echo url ('mc/fields/post', array('id' => $id));}">编辑字段</a></li>{/if}
</ul>

{if $do == 'display'}
<form action="" method="post">
<div class="panel panel-default">
	<div class="panel-heading">
		字段管理
	</div>
	<div class="panel-body table-responsive">
		<table class="table table-hover">
		<thead class="navbar-inner">
			<tr>
				<th>排序</th>
				<th>字段</th>
				<th>标题</th>
				<th>是否启用</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{loop $memberFields $field}
			<tr>
				<td>
					<input type="text" class="form-control" style="width: 50%;" name="displayorder[{$field['fieldid']}]" value="{$field['displayorder']}" />
					<input type="hidden" name="id[{$field['fieldid']}]" value="{$field['id']}" />
					<input type="hidden" name="fieldid[{$field['fieldid']}]" value="{$field['fieldid']}" />
					<input type="hidden" name="title[{$field['fieldid']}]" value="{$field['title']}" />
				</td>
				<td>{$sysFields[$field['fieldid']]['field']}</td>
				<td>{$field['title']}</td>
				<td>
					<input type="checkbox" name="available[{$field['fieldid']}]" value="1" {if $field['available']} checked {/if} />
				</td>
				<td>
					{if !empty($field['id'])}
					<a href="{php echo url('mc/fields/post', array('id' => $field['id']))}" title="编辑" class="btn btn-primary btn-sm">编辑</a>
					{/if}
				</td>
			</tr>
			{/loop}
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td>
					<input type="checkbox" id="selectAll" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});">
					<a class="btn btn-success btn-sm" style="margin-left: -25px;" onclick="$('#selectAll').click();">全选</a>
				</td>
				<td></td>
			</tr>
		</tbody>
	</table>
	</div>
	</div>
	<div>
		<button type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交">提交</button>
		<input type="hidden" name="token" value="{$_W['token']}" />
	</div>
</div>
</form>

{elseif $do == 'post'}
<div class="panel panel-default">
	<div class="panel-heading">
		编辑字段
	</div>
	<div class="panel-body">
	<form class="form-horizontal form" action="" method="post">
		<input type="hidden" name="id" value="{$item['id']}">
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">排序</label>
			<div class="col-sm-10 col-xs-12">
				<input type="text" class="form-control" name="displayorder" value="{$item['displayorder']}">
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">名称</label>
			<div class="col-sm-10 col-xs-12">
				<input type="text" class="form-control" name="title" value="{$item['title']}">
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">启用</label>
			<div class="col-sm-10 col-xs-12">
				<label for="radio_1" class="radio-inline">
					<input type="radio" name="available" id="radio_1" value="1" {if empty($item) || $item['available'] == 1} checked{/if} /> 是
				</label>
				<label for="radio_0" class="radio-inline">
					<input type="radio" name="available" id="radio_0" value="0" {if !empty($item) && $item['available'] == 0} checked{/if} /> 否
				</label>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
			<div class="col-sm-10 col-xs-12">
				<input type="submit" class="btn btn-primary" name="submit" />
				<input type="hidden" name="token" value="{$_W['token']}" />
			</div>
		</div>
	</form>
	</div>
</div>
{/if}

{template 'common/footer'}